home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 656 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: b91926@fsgi01.fnal.gov (David Sachs)
  3. Newsgroups: comp.std.c++
  4. Subject: delete or delete[] ???
  5. Date: 07 Mar 1996 15:22:36 PST
  6. Organization: FERMILAB, Batavia, IL
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4hnqvf$mgr@fsgi01.fnal.gov>
  9. Reply-To: sachs@fnal.fnal.gov
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. Summary: Is delete or delete[] correct in certain cases?
  12. Keywords: delete
  13. X-Original-Date: 7 Mar 1996 17:20:15 -0600
  14. X-Newsreader: NN version 6.5.0 #9 (NOV)
  15. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  16.     iQBVAwUBMT9vy0y4NqrwXLNJAQGTSQH+N6FqNwvxag/xlmaCd9u9A8SzjXYxE/8i
  17.     T0Uta+aN6Q06r7fAGX2fvzO9kFN+reaTepJ3M/hUeMDoDCqlo0Voxw==
  18.     =41JG
  19. Originator: austern@isolde.mti.sgi.com
  20.  
  21. Should delete or delete[] be used for a pointer to an array type?
  22.  
  23. // It is assumed that some_type is an existing type
  24. typedef some_type array_type[10];
  25.  
  26. array_type* a1 = new array_type[5];
  27. array_type* b1 = new some_type[5][10];
  28. array_type* a2 = new array_type;
  29. array_type* b2 = new some_type[10];
  30. ...
  31. delete[] a1;
  32. delete[] b1;
  33. delete   a2; // or should it be delete[] a2;
  34. delete[] b2; // or should it be delete   b2;
  35. -- 
  36. ***** Listen Americans, the IRS is your taxer,  the IRS is one. *****
  37. David Sachs - Fermilab, HPPC MS369 - P. O. Box 500 - Batavia, IL 60510
  38. Voice: 1 708 840 3942      Deparment Fax: 1 708 840 3785
  39. ---
  40. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  41.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  42.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  43.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  44.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  45. ]
  46.